/*获得所有申请*/
function getAllOrders(){
	$("table tr td").remove();
	$.ajax({
		type:"get",
		url:"findAll",
		success:function(result){
//			console.log(result.resultParm);
			for(var i=0;i<result.resultParm.placeOrder.length;i++){
				if(result.resultParm.placeOrder[i].status==0){
					var newLine = 
					"<tr>"+
						"<td>"+result.resultParm.placeOrder[i].placeOrderId+"</td>"+
						"<td>"+result.resultParm.placeOrder[i].placeId+"</td>"+
						"<td>"+result.resultParm.placeOrder[i].place.placeName+"</td>"+
						"<td>"+result.resultParm.placeOrder[i].startDate+"</td>"+
						"<td>"+result.resultParm.placeOrder[i].endDate+"</td>"+
						"<td>"+"<a title="+"\"detailsA\""+ "data-toggle="+"\"modal\""+" href="+"\'#details\'"+">详情</a>"+"</td>"+
					"</tr>";
					$("table").append(newLine);
				};
			};
			detailsA();
		},
	});
}
/*点击详情*/
function detailsA(){
	$("a[title=detailsA]").click(function(){
		var num1 = $(this).parent().parent().children().eq(0).text();
		$.ajax({
			type:"get",
			url:"findAll",
			success:function(result){
				for(var i=0;i<result.resultParm.placeOrder.length;i++){
					if(num1==result.resultParm.placeOrder[i].placeOrderId){
						$("#placeOrderId").val(result.resultParm.placeOrder[i].placeOrderId);//订单id
						$("#placeId").val(result.resultParm.placeOrder[i].place.placeId);//场地id
						$("#placeName").val(result.resultParm.placeOrder[i].place.placeName);//场地名称
						$("#startDate").val(result.resultParm.placeOrder[i].startDate);//开始时间
						$("#endDate").val(result.resultParm.placeOrder[i].endDate);//结束时间
						$("#allMoney").val(result.resultParm.placeOrder[i].allMoney);//租用价格
						$("#borrowAccount").val(result.resultParm.placeOrder[i].borrowAccount);//租用账号
						$("#borrowName").val(result.resultParm.placeOrder[i].borrowName);//姓名
						$("#telephone").val(result.resultParm.placeOrder[i].telephone);//联系方式
						$("#orderTime").val(result.resultParm.placeOrder[i].orderTime);//下单时间
					};
				};
			},
		});
		
	});
};
/*通过审核*/
$("#pass-btn").click(function(){
	var r=confirm("确认通过么？");
	if(r==true){
		$.ajax({
			type:"get",
			url:"updataStatus",
			data:{
				placeId:$("#placeOrderId").val(),
				type:1,
				},
			success:function(result){
				alert(result.resultInfo);
				$("#details").modal("hide");
				getAllOrders();
			},
			error:function(){
				alert("提交失败");
			}
		});
	};
	
});
/*不通过审核*/
$("#noPass-btn").click(function(){
	var r=confirm("确认不通过么？");
	if(r==true){
		$.ajax({
			type:"get",
			url:"updataStatus",
			data:{
				placeId:$("#placeOrderId").val(),
				type:2,
				},
			success:function(result){
				alert(result.resultInfo);
				$("#details").modal("hide");
				getAllOrders();
			},
			error:function(){
				alert("提交失败");
			}
		});
	}	
});
getAllOrders();